gtkwindow: Use default size even if not resizable
authorOlivier Fourdan <ofourdan@redhat.com>
Wed, 2 Mar 2016 10:10:29 +0000 (11:10 +0100)
committerOlivier Fourdan <ofourdan@redhat.com>
Thu, 3 Mar 2016 08:13:32 +0000 (09:13 +0100)
If a window is not resizable (with gtk_window_set_resizable ()),
the size given with gtk_window_set_default_size() is ignored.

The solution to this would be to use gtk_widget_set_size_request() but
that's a GtkWidget API and therefore does not take into account the
client side decorations when in use with GtkWindow.

Refactor the code so that gtk_window_set_default_size() (which is a
GtkWindow API) gives the expected result on non-resizable windows as
well.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=762974

gtk/gtkwindow.c

index 920f60776bf6f409d3ae170f30e1535cdac9caad..008f630094b882b1056901564179d65c9e9bae9c 100644 (file)
@@ -9133,6 +9133,14 @@ gtk_window_compute_configure_request (GtkWindow    *window,
   gtk_window_compute_configure_request_size (window,
                                              &new_geometry, new_flags,
                                              &w, &h);
+  /* If not resizeable, set min/max to what we have */
+  if (!priv->resizable)
+    {
+      new_flags |= GDK_HINT_MAX_SIZE;
+
+      new_geometry.max_width = new_geometry.min_width = w;
+      new_geometry.max_height = new_geometry.min_height = h;
+    }
 
   gtk_window_constrain_size (window,
                              &new_geometry, new_flags,
@@ -9862,13 +9870,6 @@ gtk_window_compute_hints (GtkWindow   *window,
 
       new_geometry->max_height = MAX (new_geometry->max_height, new_geometry->min_height);
     }
-  else if (!priv->resizable)
-    {
-      *new_flags |= GDK_HINT_MAX_SIZE;
-      
-      new_geometry->max_width = new_geometry->min_width;
-      new_geometry->max_height = new_geometry->min_height;
-    }
 
   *new_flags |= GDK_HINT_WIN_GRAVITY;
   new_geometry->win_gravity = priv->gravity;